﻿using iBuproModel.Repositories.Classes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using iBuproModel;
using System.Collections.Generic;

namespace IBuproModel.Tests
{
    
    
    /// <summary>
    ///This is a test class for StudentPlanRepositoryTest and is intended
    ///to contain all StudentPlanRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StudentPlanRepositoryTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for StudentPlanRepository Constructor
        ///</summary>
        [TestMethod()]
        public void StudentPlanRepositoryConstructorTest()
        {
            StudentPlanRepository target = new StudentPlanRepository();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for GetStudentFieldsForStudentPlan
        ///</summary>
        [TestMethod()]
        public void GetStudentFieldsForStudentPlanTest()
        {
            InitTest init = new InitTest();
            StudentPlanRepository target = new StudentPlanRepository(); 
            StudentPlan plan = init.GetStudentPlan();
            Assert.IsNotNull(target.GetStudentFieldsForStudentPlan(plan));


        }

        /// <summary>
        ///A test for GetSubjectsForStudentPlan
        ///</summary>
        [TestMethod()]
        public void GetSubjectsForStudentPlanTest()
        {
            InitTest init = new InitTest();
            StudentPlanRepository target = new StudentPlanRepository(); 
            StudentPlan plan = init.GetStudentPlan();
            Assert.IsNotNull(target.GetSubjectsForStudentPlan(plan));
        }

        /// <summary>
        ///A test for RemoveStudentFields
        ///</summary>
        [TestMethod()]
        public void RemoveStudentFieldsTest()
        {
            try
            {
                InitTest init = new InitTest();
                StudentPlanRepository target = new StudentPlanRepository(); 
                StudentPlan plan = init.GetStudentPlan(); 
                target.RemoveStudentFields(plan);
            }
            catch (Exception)
            {
                
                Assert.Fail();
            }
            
            
        }

        /// <summary>
        ///A test for RemoveSubjects
        ///</summary>
        [TestMethod()]
        public void RemoveSubjectsTest()
        {
            try
            {
                InitTest init = new InitTest();
                StudentPlanRepository target = new StudentPlanRepository(); 
                StudentPlan plan = init.GetStudentPlan(); 
                target.RemoveSubjects(plan);
            }
            catch (Exception)
            {

                Assert.Fail();
            }
        }


        /// <summary>
        ///A test for UpdateStudentFieldList
        ///</summary>
        [TestMethod()]
        public void UpdateStudentFieldListTest()
        {
            InitTest init = new InitTest();
            StudentPlanRepository target = new StudentPlanRepository(); 
            StudentPlan plan = init.GetStudentPlan(); 
            List<int> ids = new List<int>();

            StudentField field = init.GetStudentField();
            ids.Add(field.Id);
            
            target.UpdateStudentFieldList(plan, ids);
            Assert.IsTrue(plan.StudentFields.Contains(field));
        }

        /// <summary>
        ///A test for UpdateSubjectList
        ///</summary>
        [TestMethod()]
        public void UpdateSubjectListTest()
        {
            InitTest init = new InitTest();
            StudentPlanRepository target = new StudentPlanRepository();
            StudentPlan plan = init.GetStudentPlan();
            List<int> ids = new List<int>();

            StudentField field = init.GetStudentField();
            ids.Add(field.Id);

            target.UpdateStudentFieldList(plan, ids);
            Assert.IsTrue(plan.StudentFields.Contains(field));
        }
    }
}
